package main

import "fmt"

func main() {
	fmt.Println("-----DemoBlockedChannel-----")
	DemoBlockedChannel()
	fmt.Println("-----DemoBufferedChannel-----")
	DemoBufferedChannel()
}

func DemoBlockedChannel() {
	ch := make(chan int)
	go func() {
		ch <- 1
	}()
	go func() {
		ch <- 2
	}()
	fmt.Println(<-ch)
	fmt.Println(<-ch)
}
func DemoBufferedChannel() {

	ch := make(chan int, 2)
	ch <- 1
	ch <- 2

	fmt.Println(<-ch)
	fmt.Println(<-ch)
}
